package com.skycong.hello77.activity.autocomplete;


import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import com.skycong.hello77.R;

/**
 * @author ruanmingcong
 * @date 2018/1/7 15:29
 * 动态匹配输入内容
 */

public class AutoCompleteActivity extends Activity {
    private AutoCompleteTextView autoText;
    private String[] resouce={"app1","app2","APPle","apple1","guizhou"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.auto_activity);
        /*
        * 1，初始化控件
        * 2，需要一个适配器,
        * 3，初始化一个数据源--数据源去匹配文本框输入的内容
        * 4，将adpter与当前AutoCompleteTextView绑定
        *
        * */
        autoText = (AutoCompleteTextView) findViewById(R.id.auto_search);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,resouce);
        autoText.setAdapter(adapter);


    }
}
